import { request } from '@/service/request';
import type { LoginForm, LoginFormVo, XcxLoginForm } from './type';

export const login = (data: LoginForm) => {
  const url = '/auth/login';
  data.grantType = 'password';
  data.clientId = 'e5cd7e4891bf95d1d19206ce24a7b32e';
  return request.post<LoginFormVo>(url, data, {});
};

export const wxLogin = (xcxCode: string) => {
  const url = '/auth/login';
  const data: XcxLoginForm = {
    grantType: 'xcx',
    clientId: 'e5cd7e4891bf95d1d19206ce24a7b32e',
    xcxCode
  };
  return request.post<LoginFormVo>(url, data, {});
};
